import {Component, Input, OnInit} from '@angular/core';

@Component({
    selector: 'app-sift-filter',
    templateUrl: './sift-filter.component.html',
    styleUrls: ['./sift-filter.component.scss']
})
export class SiftFilterComponent implements OnInit {

    @Input() tagData: any;

    name1 = '全部';
    value = [];
    value1 = []; //Array<{value, label, children: Array}>

    customActionSheetOptions: any = {};

    constructor() {
    }

    ngOnInit() {
        console.log(this.tagData);
    }

    onOk1(result) {
        this.name1 = this.getResult(result);
        console.log(this.value1)
        console.log(this.name1)
    }

    getResult(result) {
        this.value = [];
        let temp = '';
        result.forEach(item => {
            this.value.push(item.label || item);
            temp += item.label || item;
        });
        return this.value.map(v => v).join(',');
    }

    getValue(result) {
        let value = [];
        let temp = '';
        result.forEach(item => {
            value.push(item.label || item);
            temp += item.label || item;
        });
        return value;
    }

    onPickerChange(result) {
        this.name1 = this.getResult(result);
        this.value1 = this.getValue(result);
    }

}
